-
Notifications
You must be signed in to change notification settings - Fork 708
fix(cam_hal): guard cam_verify_jpeg_eoi() against buffer-underflow #759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cam_hal): guard cam_verify_jpeg_eoi() against buffer-underflow #759
Conversation
No effect, still getting the same error. Just to double-check — am I only testing the changes from this PR, and not these ones #758 ? |
No, please both changes. The tag |
Tried fixes_for_m5_0.2 — no changes, same behavior |
Yeah, I found the next bug. Grab a coffee, this may take a while :D |
Enabled the flags: CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK: "y"
CONFIG_FREERTOS_CHECK_STACKOVERFLOW: "2" Here's the output from xtensa-esp32s3-elf-addr2line — hopefully this helps:
|
Yes, that's very helpful. |
I found the culprit. I'll provide another fix. |
Do not use |
Hey @me-no-dev, I'm sorry for the confusion: So #758 (which was already merged), this one, and #760 are completely independent from each other. #765 however requires all 3 independent PRs to be merged, that's why it contained the commits of the unmerged PRs. I've removed the already merged PR #758 from it. |
If DMA returns a frame shorter than two bytes, the previous code did: dptr = inbuf + length - 2; which under-flows the pointer and produces undefined behaviour. Behaviour for valid frames (length ≥ 2) is unchanged; damaged or empty buffers are now discarded safely.
db1989a
to
ee92090
Compare
ready for review and merge? |
Fixed. Ready for merge. |
Description
If DMA returns a frame shorter than two bytes, the previous code did:
which under-flows the pointer and produces undefined behaviour.
Behaviour for valid frames (length ≥ 2) is unchanged; damaged or empty buffers are now discarded safely.
Related
In the search for the cause of crashes reported by @turenkomv here: esphome/esphome#8832 (comment) I found this underflow of a pointer, which can cause undefined behaviour.
Testing
@turenkomv would you be so kind and would test this on your hardware? Tag is
fixes_for_m5_0.2
, which is the currently used version in ESPHome with both patches on top.Checklist
Before submitting a Pull Request, please ensure the following: